<div style="margin: 3px;">
颗粒物项目 {{ PrjId }} : {{ Prj.ptitle }}<br>

<a href="/Task/Create/TaskPartZooscanImport?p={{ PrjId }}" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-import"></span> 从硬盘导入样本</a>
<a href="/part/prjedit/{{ PrjId }}" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-pencil"></span> 编辑项目元信息</a>
<a href="/part/prj/" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-arrow-left"></span> 回到项目列表</a>

{{ VisibilityText |safe }}
<h4>项目样品列表 <a href="#general-help" data-toggle="collapse" class="help"> </a></h4>
<div id="general-help" class="collapse panel panel-default" style="width: 800px;margin-left: 50px;">
  <div class="panel-body">
    信息 :<br>
    这个列表可以 : <br>
* 控制已导入样品的状态<br>
* 编辑来自各个样品的元数据信息<br>
* 在你进行如下操作后重新处理直方图，匹配Ecotaxa样品，重新计算分类直方图或导入CTD数据<br>
 - 修改元数据信息<br>
 - 关联一个Ecotaxa项目<br>
 - 在Ecotaxa中标注小图<br>
 - 修改CTD文件<br>
*从项目中删除所有或选定的样品<br>
不要忘记在开始操作之前选择要重新处理的样品

  </div>
</div>
<form action="/part/prjcalc/{{ PrjId }}" method="post" id="FormSamples">
<table id="tblsample2" class="table table-bordered table-condensed" style="width: auto;">
 <thead>
  <tr>
    <th style="text-align: center;">选择
    <br><input type="checkbox" id="checkall"  >
    </th>
    <th>ID</th>
    <th>profileid</th>
    <th>filename</th>
    <th>station ID</th>
    <th>first image</th>
    <th>last img</th>
    <th>last img used</th>
    <th>Descent Filtered Rows</th>
    <th>Removed empty slice</th>
    <th>Sample Date</th>
    <th>Raw Part. Histo</th>
    <th>Det Part. Histo</th>
    <th>Reduced Part. Histo</th>
    <th>Ecotaxa Sample ID</th>
    <th>Taxonomy Histo</th>
    <th>Taxonomy Recalc Date</th>
    <th>CTD Data</th>
    <th>CTD Import Date</th>
    <th>comment</th>
  </tr>
</thead><tbody>
{% for r in dbsample %}
  <tr>
    <td><input type="checkbox" name="s_{{ r['psampleid'] }}" value="Y" ></td>
    <td>{{ r['psampleid'] }} <a href="/part/sampleedit/{{ r['psampleid'] }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
    <td>{{ r['profileid'] }}</td>
    <td>{{ r['filename'] }}</td>
    <td>{{ r['stationid'] }}</td>
    <td>{{ r['firstimage'] or ""}}</td>
    <td>{{ r['lastimg'] or ""}}</td>
    <td>{{ r['lastimgused'] or "" }}</td>
    <td>{{ r['imp_descent_filtered_row'] or "" }}</td>
    <td>{{ r['imp_removed_empty_slice'] or "" }}</td>
    <td>{{ r['sampledate'].strftime('%Y-%m-%d') if r['sampledate'] is not none else "" }}</td>
    <td>{{ r['histobrutavailable'] }}</td>
    <td>{{ r['nbrlinedet'] }}</td>
    <td>{{ r['nbrlinereduit'] }}</td>
    <td>{{ r['sampleid'] or ''}}</td>
    <td>{{ r['nbrlinetaxo'] }}</td>
    <td>{{ r['daterecalculhistotaxo']|datetime }}</td>
    <td>{{ r['nbrlinectd'] }}</td>
    <td>{{ r['ctd_import_datetime']|datetime }}</td>
    <td>{{ r['comment'] }}</td>
  </tr>
  {% endfor %}
</tbody>
</table>
<table>
  <tr >
    <td style="vertical-align: top; padding: 0 10px;"><b>功能 : </b></td>
    <td>
<input type="checkbox" name="dohistodet" value="Y"> 计算详细直方图<br>
<input type="checkbox" name="dohistored" value="Y"> 计算简化直方图<br>
<input type="checkbox" name="domatchecotaxa" value="Y"> 匹配Ecotaxa样品<br>
<input type="checkbox" name="dohistotaxo" value="Y"> 计算分类直方图<br>
<input type="checkbox" name="doctdimport" value="Y"> CTD导入
    </td>
    <td style="vertical-align: top">
      <button type="submit" class="btn btn-primary" style="width: 150px"><span class="glyphicon glyphicon-cog"></span> 执行操作</button>
  <br><button type="button" class="btn btn-xs btn-default" style="width: 150px;margin-top: 5px;" onclick="$('#checkall').click()"> 选择所有样本</button>
    </td>
  </tr>
</table>
</form>
</div>
<button type="button" onclick="$('#confirm').modal('show')" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-erase"></span> 移除选择的样本</button>

{% if Prj.instrumtype=='uvp5' %}
<br>显示导入结果图表 : {%   for i in range(0,dbsample|length,50) %} <a href="/part/prj_uvpgraph/{{Prj.pprojid}}/{{i}}" class="btn btn-primary btn-xs">页码 {{(i//50)+1}}</a>  {% endfor %}
{% endif %}

<div class="modal " id="confirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="ModalLabel">确定要移除选择的样本吗？</h4>
      </div>
      <div class="modal-body">

    <button type="button" onclick="ProcessDeleteSamples()" class="btn btn-danger"><span class="glyphicon glyphicon-erase"></span> 确认移除样本</button>

    <button  type="button" class="btn btn-warning" onclick="$('#confirm').modal('hide')"> 取消</button>

      </div>
    </div>
  </div>
</div>
<link rel="stylesheet" type="text/css" href="/static/DataTables1.10.18/DataTables-1.10.18/css/dataTables.bootstrap.min.css"/>

<script type="text/javascript" src="/static/DataTables1.10.18/DataTables-1.10.18/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/DataTables1.10.18/DataTables-1.10.18/js/dataTables.bootstrap.min.js"></script>
<style>
#tblsample2_wrapper {margin-top: -40px;}
</style>
<script>
  function ProcessDeleteSamples()
  {
    var postdata={'delete':'Y'};
    var champs=$('#FormSamples').serializeArray();
    for(i=0;i<champs.length;i++){
      var c=champs[i];
      postdata[c['name']]=c['value'];
    }
    PostDynForm("/part/prjcalc/{{ PrjId }}",postdata);
  }

$(document).ready(function(){
    $('#tblsample2').DataTable({
       "paging":   false
      ,"order": [[ 3, "desc" ]]
      ,"search": {"smart": true  }
    });

});
$('#checkall').click(function (e) {
  e.stopPropagation();
  $('#tblsample2 td input').prop('checked',$(this).prop('checked'))
});
</script>
